from .base import BaseModel

class IPDomain(BaseModel):
    """域名IP映射模型"""
    
    def __init__(self):
        super().__init__()
        self.domain = None  # 域名
        self.ip = None  # IP地址
        self.create_time = None  # 创建时间
        self.update_time = None  # 更新时间
    
    def __str__(self):
        return f"IPDomain(domain={self.domain}, ip={self.ip})"
    
    def to_dict(self):
        """将模型转换为字典格式"""
        return {
            'domain': self.domain,
            'ip': self.ip,
            'create_time': self.create_time.strftime('%Y-%m-%d %H:%M:%S') if self.create_time else None,
            'update_time': self.update_time.strftime('%Y-%m-%d %H:%M:%S') if self.update_time else None
        }